<?php
class M_history_trouble extends arfaModel{
	
	function __construct() 
	{
        parent::__construct();
		$this->table_name	= "history_trouble";
		$this->primary_key	= "ID_HISTORY_TROUBLE";
		$this->order_by		= "ID_HISTORY_TROUBLE DESC";
    }
	
	function get_data()
	{
		$this->db->select("*");
		$this->db->from($this->table_name);
		$this->db->order_by("ID_HISTORY_TROUBLE","DESC");
		$query = $this->db->get();
		
		return $query->result_array();
	}
	
	function select_data($id)
	{
		$this->db->select('*');
		$this->db->from($this->table_name);
		$this->db->where('ID_HISTORY_TROUBLE',$id);
		$query = $this->db->get();
		
		return $query->result_array();
	}
	
	function get_tanggal($get_taw,$get_tak)
	{
		$query = $this->db->query("
			SELECT 
			history_trouble.ID_HISTORY_TROUBLE,
			history_trouble.TANGGAL,
			history_trouble.JENIS_GANGGUAN,
			history_trouble.KETERANGAN,
			proses_tl_trouble.KD_TL_TROUBLE,
			proses_tl_trouble.KETERANGAN_TL,
			proses_tl_trouble.TESTIMONI
			FROM history_trouble
			LEFT JOIN proses_tl_trouble proses_tl_trouble ON history_trouble.ID_HISTORY_TROUBLE = proses_tl_trouble.KD_TL_TROUBLE
			WHERE history_trouble.TANGGAL BETWEEN '".$get_taw."' AND '".$get_tak."' AND proses_tl_trouble.TESTIMONI = 1
		");
		
		return $query->result_array();
	}
}